package Connectivity;
import java.io.*;
import java.util.Date;

 public class Logger
   {

      static String templog;
      static String url;
            
      public static String log(String data)
      {
        String c="";
        char buffer[]=new char[data.length()];
        data.getChars(0,data.length(), buffer,0);
        try
         {
        Date d1=new Date();
        String current_date=d1.getDate()+"-"+d1.getMonth()+"-"+d1.getYear();
        String file_name="CRM"+current_date+".log";
        String original_path=new File("..").getCanonicalPath();
       	String created_path=original_path+"\\server\\default\\log\\"+file_name;
       	System.out.println("created_path:::::"+created_path);
       	System.out.println("data:::::"+data);
       	File chk=new File(created_path);
       	if(chk.exists())
       	{System.out.println("all ready exists");
       		FileWriter fos=new FileWriter(created_path);      	 
   	    	fos.write(buffer);
   	    	fos.close();
       		
       	}
       	//FileInputStream fis=new FileInputStream(created_path);
       	else
       	{
       		System.out.println("Created file");
       		FileWriter fos=new FileWriter(created_path);      	 
       	    	fos.write(buffer);
       	    	fos.close();
       	}
        	 
         }

         catch(Exception e)
         {
            System.out.println(e);
         }

      return templog;
}
   }